<template>
    <div>
        <el-card class="box-card" shadow="never">
            <el-page-header @back="back" :content="content">
            </el-page-header>
            <el-form ref="form" class="edit-el-form" label-width="auto">
                <el-form-item label="客户数据导入">
                  <ExcelImport :post_url="customer_import_url" :show_file_list="show_file_list" :accept_str="accept_str" :handle_result="handle_result"></ExcelImport>
                </el-form-item>
                <el-form-item label="汽车表数据导入">
                  <ExcelImport :post_url="car_import_url" :show_file_list="show_file_list" :accept_str="accept_str" :handle_result="handle_result"></ExcelImport>
                </el-form-item>
                <el-form-item label="门店表数据导入">
                  <ExcelImport :post_url="shop_import_url" :show_file_list="show_file_list" :accept_str="accept_str" :handle_result="handle_result"></ExcelImport>
                </el-form-item>
                <el-form-item label="轮胎投保表数据导入">
                  <ExcelImport :post_url="tyre_import_url" :show_file_list="show_file_list" :accept_str="accept_str" :handle_result="handle_result"></ExcelImport>
                </el-form-item>
                <el-form-item label="历史理赔记录数据导入">
                  <ExcelImport :post_url="history_case_import_url" :show_file_list="show_file_list" :accept_str="accept_str" :handle_result="handle_result"></ExcelImport>
                </el-form-item>
            </el-form>
        </el-card>

    </div>
</template>

<script>
    import ExcelImport from '@/components/ExcelImport.vue';
    export default {
        name:'Import',
        components:{ ExcelImport },
        data() {
            return {
                customer_import_url:'/import-customer-list',
                car_import_url:'/import-car-list',
                shop_import_url:'/import-shop-list',
                tyre_import_url:'/import-tyre-list',
                history_case_import_url:'/import-history-case-list',
                show_file_list:false,
                accept_str:".csv",
                id:-1,
                content:'数据导入',
                loading:false,
                button_name:'立即提交',
            }
        },
        methods: {
            back(){
                this.$router.go(-1);
            },
            //处理excel导入的结果
            handle_result(res){
               let that=this;
               let type=res.code==1?'success':'error';
               this.$message({
                   message:res.msg,
                   type:type,
                   onClose:function(e){
                      if(res.code==1){
                        that.reload();
                      }
                   }
               });
            },
        },
        created(){

        }
    }
</script>

<style>
    .edit-el-form{
        margin-top:30px;
    }
</style>
